<template>
    <view class="user" style="position: relative;">
        <view v-for="(item, index) in state.pages" :key="index">
           <view class="bg-class" >
           	<template v-if="item.name == 'user-info'">
           	    <w-user-info
           	        :content="item.content"
           	        :styles="item.styles"
           	        :user="userInfo"
           	        :is-login="isLogin"
           	    />
           	</template>
			
           </view>
		 <view class="vip">
			 <image @click="goVipFn" class="vip-img" src="https://shengyue.yaoyunxin.cn/uploads/images/20240131/20240131090619826252424.png" mode="widthFix"></image>
		 	<!-- <image @click="goVipFn" class="vip-img" src="https://medicine.sdshengyue.cn/uploads/images/20231226/2023122616344144da25289.png" mode="widthFix" v-if="userInfo.vip_num==null&&userInfo.vip_times==null"></image> -->
			<!-- <image @click="goVipFn" class="vip-img" src="https://medicine.sdshengyue.cn/uploads/images/20240111/20240111150650018900901.png" mode="widthFix" v-if="userInfo.vip_num!=null||userInfo.vip_times!=null"></image> -->
		 </view>
            <template v-if="item.name == 'my-service'">
                <w-my-service :content="item.content" :styles="item.styles" :is-login="isLogin"/>
            </template>
            <template v-if="item.name == 'user-banner'">
                <w-user-banner :content="item.content" :styles="item.styles" />
            </template>
        </view>
		<!-- <view class="aa">
			<image class="footer-img" src="https://shengyue.yaoyunxin.cn/uploads/images/20240127/202401271104074561c5900.png" mode="widthFix"></image>
		</view> -->
        <tabbar />
    </view>
</template>

<script setup lang="ts">
import { getDecorate } from '@/api/shop'
import { useUserStore } from '@/stores/user'
import { onShow } from '@dcloudio/uni-app'
import { storeToRefs } from 'pinia'
import { reactive } from 'vue'
const state = reactive<{
    pages: any[]
}>({
    pages: []
})
const getData = async () => {
    const data = await getDecorate({ id: 2 })
    state.pages = JSON.parse(data.data)
}
const userStore = useUserStore()
const { userInfo, isLogin } = storeToRefs(userStore)
onShow(() => {
    userStore.getUser()
})
getData()

const goVipFn=()=>{
	if(isLogin.value){
		uni.navigateTo({
			url:'/pages/user/member'
		})
	}else{
		uni.navigateTo({
			url:"/pages/login/login"
		})
	}
	
}
</script>

<style lang="scss" scoped>
.vip{
	width: 94%;
	margin-left: 3%;
	position: absolute;
	top: 352rpx;
	.vip-img{
			width: 100%;
	}
}
.aa{
	display: flex;
	// justify-items: center;
	justify-content: center;
	margin-top: 60rpx;
	padding-bottom: 60rpx;
}
.footer-img{
	width: 300rpx;
	text-align: center;
}
</style>
